# Contributor: Antoine Fontaine <antoine.fontaine@epfl.ch>
# Maintainer:
pkgname=sdbus-cpp
pkgver=0.8.3
pkgrel=1
pkgdesc="unofficial, high-level C++ dbus bindings"
url="https://github.com/Kistler-Group/sdbus-cpp/"
arch="all"
license="LGPL-2.1-or-later"
makedepends="cmake elogind-dev expat-dev gtest-dev"
subpackages="$pkgname-dev $pkgname-doc"
source="sdbus-cpp-$pkgver.tar.gz::https://github.com/Kistler-Group/sdbus-cpp/archive/v$pkgver.tar.gz
	cmake.patch
	"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=None \
		-DBUILD_CODE_GEN=True \
		$CMAKE_CROSSOPTS .
	make -C build
}

dev() {
	default_dev
	# the code generator is a development tool
	mkdir "$subpkgdir"/usr/bin/
	mv "$pkgdir"/usr/bin/sdbus-c++-xml2cpp "$subpkgdir"/usr/bin/sdbus-c++-xml2cpp
}

package() {
	make -C build DESTDIR="$pkgdir" install
}

sha512sums="bdaccd686aeba9f24284c796fac7d0b6d514365e0b757db91e209e1e15c928d9de8ab1d5f5d21671896b07ea762ab4b7c6a5ce0850b17ad08bacb0f1a668cfb2  sdbus-cpp-0.8.3.tar.gz
8cb0a34426f67b865ac3bdbfbbc8ce7028d81be908aa5ea9de67fba597ef660205921d130722d14f604c6b4cbd71f235c1b800f97b2b8ce81b2617997b5056c4  cmake.patch"
